{% extends 'purchaseSys/purSysIndex.html' %}

{% block title %}
货物种类
{% endblock %}

{% block style %}
    <style>
        .right,.left{
            width: 45%;
            height: 515px;
            background-color: #d0e9c6;
            float:left;
            border:1px solid black;
            margin: 0 2% 0 2%;
        }
        table{
            width: 80%;

        }
        .add,.upd,.del{
            width: 100%;
            height: auto;
        }
        .title{
            height: 10%;
            background-color: indianred;
            font-size: 18px;
            color:white;
        }
        .table{
            margin-bottom: 0;
        }
        .btn-lg{
            padding: 0px 16px;
        }
        input[type="submit"].btn-block, input[type="reset"].btn-block, input[type="button"].btn-block {
            width: 80%;
        }
        tr{
            align: center;
        }
        .btn-lg{
            line-height: 1.5;
        }
        .table > thead > tr > th, .table > tbody > tr > th, .table > tfoot > tr > th, .table > thead > tr > td, .table > tbody > tr > td, .table > tfoot > tr > td {
        padding: 7px 0;
        line-height: 1.42857143;
        vertical-align: top;
        border-top: 1px solid #ddd;
        }
        .td_submit{
            margin-left:10%;
            {#padding-left: 20%;#}
        }
    </style>
{% endblock %}

{% block body %}
    <div class="left">
        <table class='table table-hover danger ' border="2px" cellpadding="0" cellspacing="0" >
            {% block datasshow %}
                <tr>
                    <th>编号</th>
                    <th>货物类型</th>
                </tr>
                {% for goods in all_goodstypes %}
                    <tr class="danger tr_click">
                        <td>{{ goods.id }}</td>
                        <td>{{ goods.gname }}</td>
                    </tr>
                {% endfor %}
            {% endblock %}
        </table>
    </div>
    <div class="right">
        <div id='goodstype_add' class="add">
            <form {% block add_action_form %}action="/purSysIndex/goodstype/" {% endblock %}method="post">
                <table class='table table-hover danger 'border="2px" cellpadding="0" cellspacing="0">
                <input type="hidden" name="operate" value="add">
                    <tr>
                        <td align="left" class="title">-->添加</td>
                    </tr>
                    <tr>
                        <td>
                            {% block addcontent %}
                                {{ goods_type_form.gname.label_tag }}{{ goods_type_form.gname }}<span style="color:red;">{{ msg_add }}{{ error_add }}</span>
                             {% endblock %}
                        </td>
                    </tr>
                    <tr>
                        <td class="td_submit"><input  class="btn btn-primary btn-lg btn-block active td_submit" type="submit" value="添加"></td>
                    </tr>
                </table>

            </form>
        </div>
        <div id="goodstype_upd" class="upd">
            <form {% block upd_action_form%}action="/purSysIndex/goodstype/" {% endblock %} method="post" >
                <input type="hidden" name="operate" value="upd">
                <table id='goodstype_upd_table' class='table table-hover danger ' border="2px" cellpadding="0" cellspacing="0">
                    <tr>
                        <td align="left" class="title" colspan="2">-->修改</td>
                    </tr>
                    {% block updcontent %}
                    <tr>
                        <th>编号</th>
                        <th>货物类型</th>
                    </tr>

                    <tr>
                        <td><input type="text" name="id" class="form-control"  readonly></td>
                        <td><input type="text" name="gname"  class="form-control" readonly><span style="color:red;">{{ msg_upd }}{{ error_upd }}</span></td>
                    </tr>
                     {% endblock %}
                    <tr>
                        <td colspan="2" class="td_submit"><input  class="btn btn-primary btn-lg btn-block active td_submit" type="submit"  value="修改" disabled></td>
                    </tr>
                </table>

            </form>
        </div>
        <div id="goodstype_del" class="del">
            <form {% block del_action_form%} action="/purSysIndex/goodstype/" {% endblock %}  method="post" >
                <input type="hidden" name="operate" value="del">
                <table id='goodstype_add_table' class='table table-hover danger ' border="2px" cellpadding="0" cellspacing="0">
                    <tr>
                        <td align="left" class="title" colspan="2">-->删除</td>
                    </tr>
                    {% block delcontent %}
                    <tr>
                        <th>编号</th>
                        <th>货物类型</th>
                    </tr>
                    <tr>
                        <td><input type="text" name="id" class="form-control" readonly></td>
                        <td><input type="text" name="gname" id="" class="form-control" readonly><span style="color:red;">{{ msg_del }}{{ error_del }}</span></td>
                    </tr>
                    {% endblock %}
                    <tr>
                        <td colspan="2" class="td_submit"><input  class="btn btn-primary btn-lg btn-block active td_submit" type="submit"  value="删除" disabled></td>
                    </tr>
                </table>

            </form>
        </div>

    </div>
{% endblock %}

{% block script %}
    <script>
        //删除显示 事件
        $('.tr_click').click(function () {
            $('#goodstype_upd_table tr:eq(2)>td:eq(0)>input').val($(this).children('td').first().html())
            $('#goodstype_upd_table tr:eq(2)>td:eq(1)>input').val($(this).children('td').last().html())
            $('#goodstype_upd_table tr:eq(2)>td:eq(1)>input').attr('readonly',false)

            $('#goodstype_add_table tr:eq(2)>td:eq(0)>input').val($(this).children('td').first().html())
            $('#goodstype_add_table tr:eq(2)>td:eq(1)>input').val($(this).children('td').last().html())

            $('#goodstype_upd_table > tbody > tr:nth-child(4) > td > input').attr('disabled',false)
            $('#goodstype_add_table > tbody > tr:nth-child(4) > td > input').attr('disabled',false)

        })
    </script>
{% endblock %}